import { defineStore } from 'pinia'

const fileManagement = defineStore('fileManagement', {
  state: (): {
    fileAnalysisStatus: boolean // 文件解析状态
    articleList: Element[] // 通过标题获取标题所在的段落父元素集合
    sseLoadText: string
  } => {
    return {
      fileAnalysisStatus: false,
      articleList: [],
      sseLoadText: '',
    }
  },
  getters: {
    getFileAnalysisStatus: (state) => state.fileAnalysisStatus,
    getArticleList: (state) => state.articleList,
    getSseLoadText: (state) => state.sseLoadText,
  },
  actions: {
    updatedFileAnalysisStatus(status: boolean) {
      this.fileAnalysisStatus = status
    },
    updatedArticleList(arr: Element[]) {
      this.articleList = arr
    },
    updatedSseLoadText(text: string) {
      this.sseLoadText = text
    },
  },
})
export default fileManagement
